//
//  UIImage+Extension.swift
//  WeiBo
//
//  Created by Apple on 16/9/7.
//  Copyright © 2016年 KY. All rights reserved.
//

import UIKit

extension UIImage {
    
    //  获取当前主window的截图
    static func screenShotImage() -> UIImage {
        
        //  获取当前window
        let window = UIApplication.shared.keyWindow!
        
        UIGraphicsBeginImageContext(window.size)
        //  高效的渲染方法
        window.drawHierarchy(in: CGRect(origin: CGPoint.zero, size: window.size), afterScreenUpdates: false)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        return image!
        
    }

}
